package com.sa.web.front.action;

import java.util.Date;

import com.opensymphony.xwork2.ActionSupport;
import com.sa.web.bean.EstimateBean;
import com.sa.web.dao.service.EstimateDao;
import com.sa.web.util.Util;

public class A1006 extends ActionSupport {
	
	private EstimateBean estimateInfo;
	
	private EstimateDao estimateDao;
	
	public String init () throws Exception{
		return SUCCESS;
	}
	
	
	public void validateAddEstimateInfo(){
		this.clearFieldErrors();
		if(estimateInfo == null){
			this.addFieldError("all","请填写在线评估信息");
		}else{
			if(Util.isEmpty(estimateInfo.getName())){
				this.addFieldError("name","请填写姓名");
				return;
			}
			if(Util.isEmpty(estimateInfo.getAge())){
				this.addFieldError("age","请填写年龄");
				return;
			}
			if(Util.isEmpty(estimateInfo.getSex())){
				this.addFieldError("sex","请填写 性别");
				return;
			}
			if(Util.isEmpty(estimateInfo.getPhone())){
				this.addFieldError("phone","请填写 联系电话");
				return;
			}
			if(Util.isEmpty(estimateInfo.getSchoolRecord())){
				this.addFieldError("schoolRecord","请填写 目前学历");
				return;
			}
			if(Util.isEmpty(estimateInfo.getMail())){
				this.addFieldError("mail","请填写 电子邮箱");
				return;
			}
			if(Util.isEmpty(estimateInfo.getAddress())){
				this.addFieldError("address","请填写 现居住城市");
				return;
			}
			if(Util.isEmpty(estimateInfo.getCountries())){
				this.addFieldError("countries","请填写 意向留学国家");
				return;
			}
			if(Util.isEmpty(estimateInfo.getPlanTarget())){
				this.addFieldError("planTarget","请填写 计划完成目标");
				return;
			}
			if(Util.isEmpty(estimateInfo.getResult())){
				this.addFieldError("result","请填写 语言考试成绩");
				return;
			}
			if(Util.isEmpty(estimateInfo.getSchoolTime())){
				this.addFieldError("schoolTime","请填写 预计留学时间");
				return;
			}
			
		}
	}
	
	public String addEstimateInfo () throws Exception{
		estimateInfo.setId(Util.getUUID());
		estimateInfo.setCreateDate(Util.dateToString(new Date()));
		estimateDao.addEstimateInfo(estimateInfo);
		return SUCCESS;
	}

	public EstimateBean getEstimateInfo() {
		return estimateInfo;
	}

	public void setEstimateInfo(EstimateBean estimateInfo) {
		this.estimateInfo = estimateInfo;
	}

	public void setEstimateDao(EstimateDao estimateDao) {
		this.estimateDao = estimateDao;
	}

}
